/*
 * ========THE SOLMIX PROJECT=====================================
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.gnu.org/licenses/ 
 * or see the FSF site: http://www.fsf.org. 
 */
package org.solmix.event;

import org.solmix.services.criterion.ErrorMessage;
import org.solmix.services.criterion.ValidationEventLocator;


/**
 * 
 * @author solomon
 * @version $Id$  2011-10-5
 */

public abstract class AbstractValidationEvent implements IValidationEvent,java.io.Serializable
{
    protected Throwable exception;

    protected Status status;

    protected Level severity;

    protected OutType outType;

    protected String name;
    ErrorMessage errorMessage;
    org.solmix.services.criterion.ValidationEventLocator locator;
    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#getErrorMessage()
     */
    @Override
    public ErrorMessage getErrorMessage() {
        return errorMessage;
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#getStuts()
     */
    @Override
    public Status getStuts() {
        return status;
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#setStatus(org.solmix.event.IValidationEvent.Status)
     */
    @Override
    public void setStatus(Status value) {
       this.status=value;
        
    }


    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#getName()
     */
    @Override
    public String getName() {
        return name;
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#getException()
     */
    @Override
    public Throwable getException() {
        return exception;
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#getOutType()
     */
    @Override
    public OutType getOutType() {
        return outType;
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#setOutType(org.solmix.event.IValidationEvent.OutType)
     */
    @Override
    public void setOutType(OutType outType) {
        this.outType = outType;
        
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#getLevel()
     */
    @Override
    public Level getLevel() {
        return severity;
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#setLevel(org.solmix.event.IValidationEvent.Level)
     */
    @Override
    public void setLevel(Level _severity) {
        if ( _severity != Level.DEBUG && _severity != Level.WARNING && _severity != Level.ERROR )
        {
           throw new IllegalArgumentException( "bad severity data" );
        }

        this.severity = _severity;
        
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#setErrorMessage(org.solmix.services.criterion.ErrorMessage)
     */
    @Override
    public void setErrorMessage(ErrorMessage errorMessage) {
        this.errorMessage = errorMessage;
        
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#setException(java.lang.Throwable)
     */
    @Override
    public void setException(Throwable exception) {
        this.exception = exception;
        
    }

    /**
     * {@inheritDoc}
     * 
     * @see org.solmix.event.IValidationEvent#setLocator(org.solmix.services.criterion.ValidationEventLocator)
     */
    @Override
    public void setLocator(ValidationEventLocator locator) {
        this.locator = locator;
    }

}
